package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mappers.BlackListMapper;
import com.tanhua.dubbo.mappers.UserInfoMapper;
import com.tanhua.model.domain.BlackList;
import com.tanhua.model.domain.UserInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class BlackListApiImpl implements BlackListApi {

    @Autowired
    private BlackListMapper blackListMapper;
    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public void deleteBlackList(Long userId, Long blackUserId) {
        LambdaQueryWrapper<BlackList> lambdaQueryWrapper=new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(BlackList::getUserId,userId)
                            .eq(BlackList::getBlackUserId,blackUserId);
        blackListMapper.delete(lambdaQueryWrapper);
    }

    @Override
    public IPage<UserInfo> findByUserId(Long userId, Integer page, Integer pagesize) {
//1、构建分页参数对象Page
        Page iPage=new Page(page,pagesize);
//2、调用方法分页（自定义编写 分页参数Page，sql条件参数）

        return userInfoMapper.findBlackList(iPage,userId);
    }
}